package com.cskaoyan.mall.user.controller.inner;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cskaoyan.mall.user.converter.UserAddressConverter;
import com.cskaoyan.mall.user.dto.UserAddressDTO;
import com.cskaoyan.mall.user.mapper.UserAddressMapper;
import com.cskaoyan.mall.user.model.UserAddress;
import com.cskaoyan.mall.user.service.UserAddressService;
import com.cskaoyan.mall.user.service.UserService;
import net.sf.jsqlparser.expression.LongValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Pudding
 * @Date 2024/7/17 10:07
 */
@RestController
public class UserApiController {

    @Autowired
    UserAddressService userAddressService;
    @Autowired
    UserAddressConverter userAddressConverter;

    /**
     * 根据userId查询user中address表即可
     * @param userId
     * @return
     */
    @GetMapping("/api/user/inner/findUserAddressListByUserId/{userId}")
    public List<UserAddressDTO> findUserAddressListByUserId(@PathVariable("userId") String userId){

        List<UserAddress> userAddressList = userAddressService.findUserAddressListByUserId(userId);

        //2. 将userAddressList转换为UserAddressDTO
        List<UserAddressDTO> userAddressDTOS = userAddressConverter.userAddressPOs2DTOs(userAddressList);
        return userAddressDTOS;
    }
}
